<template>
	<view class="content" >
			<view v-if="show_main" class="main" >
			
				<view @click="goPage" data-uri="/pages/article/accord" class="bgf p30 f32 disfr-lr bto">
					<view class="pt10">
						<u-icon name="xieyi" color="#2979ff" custom-prefix="qxl-icon" style="position: relative;top:3rpx;" size="48"></u-icon>
						<text>用户协议</text>
					</view>
					<view class="disf pr col999" style="top:5rpx;">
						<u-icon name="arrow-right" size="44"></u-icon>
					</view>
				</view>
				
				<view @click="goPage" data-uri="/pages/article/privacypolicy" class="bgf p30 f32 disfr-lr bto">
					<view class="pt10">
						<u-icon name="yinsizhengce" color="#19be6b" custom-prefix="qxl-icon" style="position: relative;top:3rpx;" size="44"></u-icon>
						<text>隐私政策</text>
					</view>
					<view class="disf pr col999" style="top:5rpx;">
						<u-icon name="arrow-right" size="44"></u-icon>
					</view>
				</view>
				
				<!--<view class="bgf p30 f32 disfr-lr bto">
					<view class="pt10">
						<u-icon name="xiugaimima" color="#07C160" custom-prefix="qxl-icon" style="position: relative;top:3rpx;" size="48"></u-icon>
						<text>更换手机</text>
					</view>
					<view class="disf pr col999" style="top:5rpx;">
						<u-icon name="arrow-right" size="44"></u-icon>
					</view>
				</view>-->
				
				<view @click="cancelAccount" class="bgf p30 f32 disfr-lr bto">
					<view class="pt10">
						<u-icon name="yichu" color="red" custom-prefix="qxl-icon" style="position: relative;top:4rpx;" size="48"></u-icon>
						<text>注销帐号</text>
					</view>
					<view class="disf pr col999" style="top:5rpx;">
						<u-icon name="arrow-right" size="44"></u-icon>
					</view>
				</view>
				<view class="bgf p30 f32 disfr-lr bto">
					<view class="pt10">
						<u-icon name="bangzhu" color="#ff9900" custom-prefix="qxl-icon" style="position: relative;top:4rpx;" size="44"></u-icon>
						<text class="ml5">版本号</text>
					</view>
					<view class="disf pr col999" style="top:5rpx;">{{app_version}}
						<!--<u-icon name="arrow-right" size="44"></u-icon>-->
					</view>
				</view>
				<view class="mt100 p30">
					<button class="my_button"  @click="logout"
					style="background: #eee;border: 1px solid #ccc;color:#666666;border-radius: 20px;">退出登录</button>
				</view>
			</view>
			
		<loading :loading="not_load"/><!--加载状态-->
		<!--用户协议-->
		<u-popup v-model="accordShow" mode="bottom" border-radius="14" height="80%" :closeable="true">
			<view class="mt30 b f34 bbo pb20 popup-title"><text class="ml30">用户协议</text></view>
			<view style="height: 47px;"></view>
			<view class="p30 f32" style="line-height: 180%;"> <rich-text :nodes="content"></rich-text></view>
		</u-popup>
	</view>
</template>

<script setup>
import { onLoad, onShow, onHide, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app';
import { ref } from 'vue';	
const show_main=ref(true);
const not_load=ref(true);
const app_name=ref('');
const app_version=ref('');
// #ifndef MP || MP-WEIXIN
plus.runtime.getProperty(plus.runtime.appid, (info)=> {
	app_version.value='V'+info.version;
});
// #endif
//弹出用户协
const content=ref('');
const accordShow=ref(false);
const showAccord=()=>{
	accordShow.value=true;
};
//页面加载时
onLoad(async (options)=>{

});
//页面显示时执行
onShow(()=>{
	//console.log('语法糖onShow');
	 loadPage({},false);
});
//页面隐藏时执行
onHide(()=>{
	//console.log('语法糖onHide');
});
/**
 * 加载接口数据
 * @param {Object} options  参数,对像数组
 * @param {Object} isPage   是否加载大于1页
 */
const loadPage=async (options,isPage)=>{
	let ret = await uni.$get('/appapi-article-accord',options);
	if(ret.error_code != 0){
		uni.$utils.showToast(ret.info);
		return;
	}
	not_load.value=true;
	content.value=ret.data.cn_content1;
	app_name.value=ret.data.app_name;
};
/**
 * 模板属性跳转页面
 * @param {Object} e
 */
function goPage(event){
	uni.$utils.dataSetPage(event);
};
// 退出登录
const logout=()=>{
	uni.$utils.showModal('确认退出登录?',1,async()=>{
		emptyLogin();
	});
};
//注销帐号
const cancelAccount=async()=>{
	uni.$utils.showModal('操作不可恢复,确认注册帐号?',1,async()=>{
		let ret=await uni.$get('/appapi-member-cancellation');
		if(ret.error_code != 0){
			uni.$utils.showToast(ret.info);
			return;
		}
		uni.$utils.showToast('帐号注销成功',0,()=>{
			emptyLogin();
		});
	});
};

//清空登录状态
const emptyLogin=()=>{
	/*for(let i in uni.$vuex.state.globalData.conversationList){
		uni.TIM.deleteConversation(uni.$vuex.state.globalData.conversationList[i].conversationID);
	}*/
	uni.$vuex.state.globalData.conversationList=[];
	uni.$vuex.state.globalData.imLoginStatus=false;
	uni.$vuex.state.globalData.user={};
	uni.$utils.setCache('tencentimsig',null);
	uni.$unsetToken();
	uni.TIM.logout();
	//console.log('退出');
	uni.$utils.goPage('/pages/login-app/login-app',2);
};
</script>

<style  lang="scss">
	page {
		
	}
.fnow{color:#2979ff;}
.my_button{
	color:#fff;
	font-weight: normal;
	font-size: 32rpx;
	border:none;
	background: blue;
	background: #2979ff;
}
</style>
